<!DOCTYPE html>
<meta charset="utf-8">
<title>Insecure inscope page</title>
<script>
// The top window messages us when it wants to check for a controller.
window.onmessage = (async e => {
  if (navigator.serviceWorker) {
    window.top.postMessage('FAIL: navigator.serviceWorker is defined on an insecure context', '*');
    return;
  }

  // Perform a fetch() to detect whether a service worker controls this page.
  const response = await fetch('simple.txt');
  const text = await response.text();
  if (text != 'a simple text file\n') {
    window.top.postMessage('FAIL: fetched ' + text, '*');
    return;
  }
  window.top.postMessage('PASS', '*');
});
</script>
